/* INCLUDES ******************************************************************/

#include <avr/io.h>
#include "ses_led.h"
#include "ses_common.h"

/* FUNCTION DEFINITION *******************************************************/

void led_redInit(void) {
	DDR(LED_RED_PORT) |= (1 << LED_RED_PIN);
}

void led_redToggle(void) {
	PIN(LED_RED_PORT) ^= (1 << LED_RED_PIN);
}

void led_redOn(void) {
	PIN(LED_RED_PORT) |= (1 << LED_RED_PIN);
}

void led_redOff(void) {
	PIN(LED_RED_PORT) &= (0 << LED_RED_PIN);
}

void led_yellowInit(void) {
	DDR(LED_YELLOW_PORT) |= (1 << LED_YELLOW_PIN);
}

void led_yellowToggle(void) {
	PIN(LED_YELLOW_PORT) ^= (1 << LED_YELLOW_PIN);
}

void led_yellowOn(void) {
	PIN(LED_YELLOW_PORT) |= (1 << LED_YELLOW_PIN);
}

void led_yellowOff(void) {
	PIN(LED_YELLOW_PORT) &= (0 << LED_YELLOW_PIN);
}

void led_greenInit(void) {
	DDR(LED_GREEN_PORT) |= (1 << LED_GREEN_PIN);
}

void led_greenToggle(void) {
	PIN(LED_GREEN_PORT) ^= (1 << LED_GREEN_PIN);
}

void led_greenOn(void) {
	PIN(LED_GREEN_PORT) |= (1 << LED_GREEN_PIN);
}

void led_greenOff(void) {
	PIN(LED_GREEN_PORT) &= (0 << LED_GREEN_PIN);
}

void mydelay(uint16_t mili) {
	uint16_t i;
	for (i = 0x0000; i <= mili; i++) {
		asm volatile ("NOP");
	}
}

int main (void) {
	led_redInit();
	led_yellowInit();
	led_greenInit();
	while(1){
		led_greenOn();
		mydelay(5000);
		led_greenToggle();
		led_yellowOn();
		mydelay(500);
		led_yellowOff();
		led_redOn();
		mydelay(2000);
		led_yellowOn();
		mydelay(300);}
	return 0;
}

